var request = require('./request.js');

module.exports = {

  /**
   * 刷新access token
   * 
   * @param refreshToken 刷新令牌
   */
  refreshToken(refreshToken) {
    return request.post('/mbr/member/refreshToken', {
      refreshToken: refreshToken
    })
  },
  /**
   * 获得会员储值余额
   */
  getMbrBalance: function () {
    return request.get('/mbr/member/getMbrBalance')
  },
  /**
   * 重置会员储值卡密码
   * @param newPassword 新密码
   * @param oldPassword 旧密码
   */
  resetCardPassword: function (postData) {
    return request.post('/mbr/member/resetCardPassword', postData)
  },
  /**
   * 记录会员访问门店：同一天同一个门店，同一个会员访问只会被记录一次
   */
  visitStore: function (storeId) {
    return request.put('/mbr/member/visitStore?storeId=' + storeId)
  },
  /**
   * 分页查询储值流水信息
   */
  query: function (postData) {
    return request.get('/mbr/cardPay/query', postData)
  },
  /**
   * 会员积分查询
   */
  getBalance: function (memberMobile) {
    var params = {
      memberMobile: memberMobile
    }
    return request.get('/mbr/score/getBalance', params)
  },
  /**
   * 查询积分流水
   */
  queryHst: function (page, pageSize, mobile) {
    var params = {
      memberMobileEquals: mobile,
      page: page,
      pageSize: pageSize,
      orderDirection: 'desc',
      orderField: 'tranTime'
    }
    return request.get('/mbr/score/queryHst', params)
  },
  /**
   * 查询积分抵扣金额
   * @param memberScore 会员积分
   * @param orderPrice 订单价格 ： 订单商品价格(不算运费不算优惠)
   * @param orderScore 使用积分
   */
  getScoreDeutible: function (memberScore, orderPrice, orderScore) {
    var params = {
      memberScore: memberScore,
      orderPrice: orderPrice,
      orderScore: orderScore
    }
    return request.get('/mbr/score/getScoreDeutible', params)
  },
  /**
   * 邀请好友，好友领取
   * @param postData 包含下面参数
   * @param captcha  短信验证码  
   * @param introduceStoreId 邀请门店id：当邀请人为门店时，该字段必传 
   * @param introducerId 邀请人id：当邀请人为会员时，该字段必传 
   * @param inviteeMobile 被邀请人手机号
   */
  invite: function (postData) {
    return request.post('/mbr/member/invite', postData)
  },
  /**
   * 获得会员付款码
   */
  getPayCode: function (postData) {
    return request.get('/mbr/member/getPayCode', postData)
  },
  /**
   * 会员签到对外接口
   */
  signin: function () {
    return request.post('/mbr/signin')
  },
  /**
   * 会员签到查询对外接口
   */
  querySignin: function () {
    return request.get('/mbr/signin/query')
  }
}